//  我的-部门管理-恭喜寄语设置
const baseUrl='https://gsdse.cn/api/KJRecruit';
const app = getApp();

Page({

  /**
   * 页面的初始数据
   */
  data: {
    content: '',
    department: '',
    personInfo: '',
    congrats: '',
    congratulation: ''
  },

  //--------------------------------------
  //methods

  inputContent(e) {
    // console.log(e);
    this.setData({
      content: e.detail.value
    });
    console.log(this.data.content);
  },

  save(e) {
    
    if (this.data.content != '') {
      wx.request({
        url: baseUrl+'/updateDepartment',
        method: 'POST',
        header: {
          "Content-Type": "application/x-www-form-urlencoded"
        },
        data: {
          "departmentId": this.data.personInfo.departmentId,
          "applyNumber": this.data.department.applyNumber,
          "identification": this.data.department.identification,
          "_key": this.data.department._key,
          "notice": this.data.department.notice,
          "congratulation": this.data.content
        },
        success: (res) => {
          if (res.data.code == 0) {
            wx.showToast({
              icon: 'none',
              title: '修改成功',
            })
          }
        }
      })
    }else{
      wx.showToast({
        icon:'none',
        title: '当前内容为空',
      })
    }

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    //获取全局变量personInfo和department
    this.setData({
      personInfo: app.data.personInfo,
      department: app.data.department
    })
    console.log("onLoadDepartment", this.data.department);
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    this.setData({
      personInfo: app.data.personInfo,
      department: app.data.department,
      content:app.data.department.congratulation
    })
    console.log("onShowDepartment", this.data.department);

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})